import React from 'react';
import { Form, Select } from 'antd';

// 定义组件的属性类型接口
interface SummarySelectProps {
    name: string;
    label: string;
    required: boolean;
    options: string[];
    onChange: (value: string) => void;
}

const SummarySelect = (props: SummarySelectProps) => {
    const { name, label, required, options, onChange } = props;

    const handleChange = (value: string) => {
        onChange(value)
    }
    return (
        <Form.Item label={label} name={name} required={required} rules={[{ required: required, message: `请选择${label}` }]}>
            <Select onChange={handleChange}>
                {options.map((item, idx) => (
                    <Select.Option key={idx} value={item}>{item}</Select.Option>
                ))}
            </Select>
        </Form.Item>
    );
};

export default SummarySelect;